package com.shape;

public class Rectangle implements ShapeInterface {
    double width;
    double height;
    private String shape = "长方形";
    double[] params;

    public Rectangle(){};

    public Rectangle(double[] arr) {
        this.width = arr[0];
        this.height = arr[1];
        this.params = arr;
        if(this.width == this.height){
            this.shape = "正方形";
        }
    }

    @Override
    public double perimeter() {
        return ((this.width + this.height) * 2);
    }

    @Override
    public double area() {
        return (this.width * this.height);
    }

    public String getShape() {
        return this.shape;
    }

    public void printParams(){
        for(int i = 0; i < this.params.length; i++){
            System.out.println("当前是第"+ i +"个值：" + this.params[i]);
        }
    }
}
